<template>
  <div class="m-contain edit edit-address">
    <van-nav-bar title="编辑地址"
                 left-arrow
                 @click-left="onClickLeft" />
    <div class="m-main">
      <van-address-edit :area-list="areaList"
                        show-set-default
                        show-search-result
                        save-button-text='保存地址'
                        :search-result="searchResult"
                        :area-columns-placeholder="['请选择', '请选择', '请选择']"
                        @save="onSave"
                        @delete="onDelete"
                        @change-detail="onChangeDetail" />
    </div>
  </div>
</template>
<script>

import Vue from 'vue';
import areaList from '@/assets/js/address.js'
import { NavBar, AddressEdit, Button } from 'vant';
import { Toast } from 'vant';
Vue.use(NavBar);
Vue.use(AddressEdit);
Vue.use(Button);
export default {
  name: "userInfo",
  data() {
    return {
      value: '',
      areaList,
      searchResult: [],
    }
  },
  components: {
  },
  mounted() {
  },
  methods: {
    onClickLeft() {
      this.$router.replace('/user/addresslist')
    },
    onSave() {
      Toast('save');
    },
    onDelete() {
      Toast('delete');
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: '黄龙万科中心',
            address: '杭州市西湖区',
          },
        ];
      } else {
        this.searchResult = [];
      }
    },
  }
}
</script>

<style >
.edit-address .van-image__img {
  margin-top: 10px;
}
.edit-address .van-cell__label {
  color: #333333;
}

.edit-address .van-button {
  width: 100%;
}
.edit-address .van-switch--on {
  background-color: #e62b4b;
}
.edit-address .van-button--danger {
  background-color: #e62b4b !important;
  border: 1px solid #e62b4b !important;
}
</style>

<style lang="less" scoped>
.edit {
  min-height: 100vh;
  width: 100%;
  background-color: #fff;
  .van-cell {
    height: 63px;
  }
}
.btn {
  height: 46px;
  width: 82%;
  margin: 0 auto;
  margin-top: 300px;
}
</style>